﻿using System.Collections.Generic;
using System.Linq;

namespace eStock.DataObjects
{
    public class Tray
    {
        public int Id { get; set; }
        public int ComponentId { get; set; }
        public Component Component { get { return DatabaseObjects.Components != null ? DatabaseObjects.Components.GetById(ComponentId) : null; } }
        public int BoxId { get; set; }
        public List<int> ShopIds { get; private set; }
        public List<Address> Shops
        {get{
            List<Address> shops = new List<Address>();
            if(DatabaseObjects.Addresses != null)
            {
                shops.AddRange(ShopIds.Select(shopId => DatabaseObjects.Addresses.GetById(shopId)));
            }
            return shops;
        }
        }
        public string Title { get; set; }
        public int Amount { get; set; }
        public double Price { get; set; }
        public ConditionType Condition { get; set; }
        public string Description { get; set; }

        public Tray()
        {
            ShopIds = new List<int>();
        }
    }

    public enum ConditionType
    {
        Neu = 0,
        Gebraucht = 1,
        Unbrauchbar = 2,
        Sonstiges = 3
    }
}
